home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4759 < prev    next >
Encoding:
Text File  |  1996-08-06  |  920 b   |  39 lines

  1. Path: news.uiowa.edu!usenet
  2. From: larued@crpl.cedar-rapids.lib.ia.us
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Argument from commandline???
  5. Date: 1 Feb 1996 00:53:20 GMT
  6. Organization: University of Iowa, Iowa City, IA, USA
  7. Distribution: world
  8. Message-ID: <4ep2u0$nho@flood.weeg.uiowa.edu>
  9. References: <4eou36$p6g@prometheus.algonet.se>
  10. Reply-To: larued@crpl.cedar-rapids.lib.ia.us
  11. NNTP-Posting-Host: ppp-109.cedar-rapids.lib.ia.us
  12. X-Newsreader: IBM NewsReader/2 v1.9d - NLS
  13.  
  14. In <4eou36$p6g@prometheus.algonet.se>, bifrost@algonet.se (Nylund Patrik) writes:
  15. >How do I include argument from the commandline to the main function in
  16. >a c++ program?
  17. >
  18. >
  19.  
  20.   Nylund,
  21.  
  22.   The same as in C.
  23.  
  24. === Example
  25.  
  26. #include <iostream.h>
  27.  
  28. int main (int argc, char *argv[])
  29. {
  30.   int a;
  31.  
  32.   cout << "There are " << argc << " arguments.\n";
  33.  
  34.   for (a = 0; a < argc; ++a)
  35.    {
  36.      cout << "Argumnt " << argc << "is \"" << argv[a] << "\"\n");
  37.    }
  38. }
  39.